package com.android.cl.coludtf.utils.sharedPreferences;

import com.android.cl.coludtf.model.BaseBO;

public class DatabaseHelper {
    /**
     * 登录账号
     */
    public static String ACCOUNT = "login_account";
    /**
     * 登录密码
     */
    public static String PASSWORD = "login_password";
    /**
     * 登录token
     */
    public static String TOKEN = "login_token";
    /**
     * 租户列表
     */
    public static String TENANTS = "tenant_list";

    /**
     * 获得基本信息
     *
     * @return
     */
    public static BaseBO getBaseBO() {
        BaseBO ret = new BaseBO();
        ret.account = SharedPreferencesHelper.get(ACCOUNT, ret.account);
        ret.password = SharedPreferencesHelper.get(PASSWORD, ret.password);
        ret.token = SharedPreferencesHelper.get(TOKEN, ret.token);
        ret.tenants = SharedPreferencesHelper.get(TENANTS, ret.tenants);
        return ret;
    }

    public static String getValue(String key) {
        return SharedPreferencesHelper.get(key, key);
    }

    /**
     * 保存基本信息
     *
     * @param
     * @return
     * @throws Exception
     */
    public static boolean updateBo(BaseBO bo) {
        SharedPreferencesHelper.put(ACCOUNT, bo.account);
        SharedPreferencesHelper.put(PASSWORD, bo.password);
        SharedPreferencesHelper.put(TOKEN, bo.token);
        SharedPreferencesHelper.put(TENANTS, bo.tenants);

        return true;
    }

    public static boolean update(String key, String value) {
        SharedPreferencesHelper.put(key, value);
        return true;
    }

}
